<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>商品列表</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-4">
    <h1>商品列表</h1>
    
    <a th:href="@{/products/add}" class="btn btn-primary mb-3">添加商品</a>
    
    <table class="table table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>商品名称</th>
                <th>价格</th>
                <th>库存</th>
                <th>描述</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            <tr th:each="product : ${products}">
                <td th:text="${product.id}"></td>
                <td th:text="${product.name}"></td>
                <td th:text="'¥' + ${#numbers.formatDecimal(product.price, 1, 2)}"></td>
                <td th:text="${product.stock}"></td>
                <td th:text="${product.description}"></td>
                <td>
                    <a th:href="@{/products/edit/{id}(id=${product.id})}" class="btn btn-warning btn-sm">编辑</a>
                    <a th:href="@{/products/delete/{id}(id=${product.id})}" class="btn btn-danger btn-sm" 
                       onclick="return confirm('确定删除这个商品吗？')">删除</a>
                </td>
            </tr>
        </tbody>
    </table>
</div>
</body>
</html>